# Wrappers for Python, should not be Tk-specific

class Callable:
	def __init__(self, func, *args, **kwds):
		self.func = func
		self.args = args
		self.kwds = kwds
	def __call__(self, event=None):
		return apply(self.func, self.args, self.kwds)
	def __str__(self):
		return self.func.__name__

class PseudoFile(object):
	def __init__(self, writefn, name='', encoding=None):
		self.writefn = writefn
		self.name = name
	def write(self, s):
		self.writefn(s)
	def writelines(self, l):
		map(self.write, l)
	def flush(self):
		pass
	def isatty(self):
		return True

def isDirectory(dir_name):
	import os
	mask = 040000
	try: s = os.stat(dir_name)
	except: return 0
	if (mask & s[0]) == mask: return 1
	else: return 0

def makeThread(fn, args=None): #fn, args as a tuple
	if args==None: args=tuple()
	import threading
	t = threading.Thread( target=fn, args=args)
	t.start()
	